<?php 
include('../common/_const.php');
include('../common/common.php');
include('../common/checksession.php');
checksession("../index.php");
include('../../inc/conn.php');
date_default_timezone_set('Asia/Chongqing');//设置时区

//获取栏目id
$typeid=$_GET['catid'];
//获取页码
$pagenum=$_GET['pages'];
isnum($typeid,"栏目id错误","catalog_main.php");
if(!is_numeric($pagenum)||$pagenum<=0){
	ShowMsg_h("参数错误","content_list.php?catid=".$typeid."&pages=1");
	exit;
}
$pagenum--;

//数据库连接
$db=db_connect();
$sql_type=select_sql("`typename`,`channeltype`","`".PRETABLE."arctype`","`id`='".$typeid."'");
$rs=$db->query($sql_type) or die("datebase error!");
$count=$rs->num_rows;
$channelid=$rs->fetch_assoc();
$channelid=$channelid['channeltype'];// 调出频道id

if(!$count){
	ShowMsg_h("没有这个栏目!","../moduls/catalog_main.php");
	exit;
}
$typename_all=array();
$sql_type=select_sql("`typename`,`id`","`".PRETABLE."arctype`","1=1");
$rs=$db->query($sql_type) or die("datebase error!");
while($typename=$rs->fetch_assoc()){//栏目列表赋值
	$typename_all[$typename['id']]=$typename['typename'];
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../images/css1/list.css" rel="stylesheet" type="text/css">
<title><?php echo $sys_title['add_article']; ?></title>
<script type="text/javascript">
function del_check(){
	
	var flag=false;

	for(i=0;i<document.forms[0].elements.length;i++){
		if(document.forms[0].elements[i].type=="checkbox"){
			if(document.forms[0].elements[i].value!="0" && document.forms[0].elements[i].checked){
				flag=true;
				break;
			}
		}
	}
	if(!flag){
		alert("你要选择要删除的文章!");
		return false;
	}

	
	if(window.confirm("确认删除选中文章!")){
		document.getElementById('delform').submit()
	}
}
</script>
</head>

<body>
<div class="top_bar">
	
    <div class="titbut"><a href="arcback_list.php?pages=1">文章回收站</a></div>
    <div class="titbut"><a href="#" onclick="del_check();">删除文档</a></div>
    <div class="titbut">
    <?php if($channelid==1){?>
    <a href="article_add.php?catid=<?php echo $typeid;  ?>">添加文档</a>
    <?php }else if($channelid==2){?>
    <a href="article_img_add.php?catid=<?php echo $typeid;  ?>">添加文档</a>
    <?php }?>
    </div>
</div>
<div class="pos_now">当前位置：<a href="../index_body.php">首页</a> > <a href="catalog_main.php">栏目管理</a> > <?php echo $typename_all[$typeid]; ?> ></div>
<form method="post" action="../action/ac_tallerdel.php" id="delform">
<table class="con_list">
  <tr>
  	<th width="5%" align="center">选择</th>
    <th width="7%" align="center">ID</th>
    <th align="center">标题</th>
    <th width="10%" align="center">发布时间</th>
    <th width="10%" align="center">类目</th>
    <th width="7%" align="center">状态</th>
    <th width="7%" align="center">点击</th>
    <th width="5%" align="center">评论</th>
    <th width="11%" align="center">操作</th>
    
  </tr>
  <?php 
  	$pagesize=8;
	
  	$sql_arc_count=select_sql("*","`".PRETABLE."arcmain`","`typeid`='".$typeid."' AND `isdel`='0' ORDER BY `pubdate` ");
  	$sql_arc=select_sql("*","`".PRETABLE."arcmain`","`typeid`='".$typeid."' AND `isdel`='0' ORDER BY `pubdate` DESC LIMIT ".$pagenum*$pagesize.",".$pagesize);
	$rs=$db->query($sql_arc_count) or die("datebase error!");
	
	$arc_count=$rs->num_rows;//文档个数
	$max_pages=$arc_count%$pagesize?(int)($arc_count/$pagesize)+1:(int)($arc_count/$pagesize);
	
	$rs=$db->query($sql_arc) or die("datebase error!");
	while($row=$rs->fetch_assoc()){
  ?>
  <tr>
    <td align="center"><input type="checkbox" name="beach_del[]" value="<?php echo $row['id']; ?>" /></td>
    <td align="center"><?php echo $row['id']; ?></td>
    <td style="text-indent:6px;"><a href="article_edit.php?aid=<?php echo $row['id'] ?>"><?php echo $row['title']; ?></a></td>
    <td align="center"><?php echo date("Y-m-d",$row['pubdate']); ?></td>
    <td align="center"><?php echo $typename_all[$row['typeid']]; ?></td>
    <td align="center"><?php if ($row['ishidden']){echo "<font color='red'>待审核</font>";}else{echo "显示";} ?></td>
    <td align="center"><?php echo $row['click']; ?></td>
    <td align="center"><?php echo $row['isguest']?"是":"否"; ?></td>
    <td align="center"><a href="article_edit.php?aid=<?php echo $row['id'] ?>">[编缉]</a><a href="../action/ac_del_arc.php?aid=<?php echo $row['id'] ?>">[删除]</a></td>
  </tr>
  <?php 
	}
	$rs->close();
	$db->close();
  ?>
</table>
</form>
<div class="pos_now" style="text-align:center;">
<?php for($i=1;$i<=$max_pages;$i++){?>
<a href="content_list.php?catid=<?php echo $typeid; ?>&pages=<?php echo $i ?>" <?php echo $pagenum+1==$i?"class=\"current\"":"";?>><?php echo $i ?></a>
<?php }?>&nbsp;&nbsp;&nbsp;&nbsp;
共 <?php echo $max_pages; ?> 页/<?php echo $arc_count; ?> 条记录
</div>
<div class="top_bar">
<form name="search" method="get" action="search_list.php">
<table style="width:100%; height:100%; border-collapse:collapse;">
  <tr>
    <td align="right" width="15%">
    <?php 
	if($typeid){
		foreach($typename_all as $v=>$k){
		if($v==$typeid){echo "搜索栏目：".$k; echo "<input type='hidden' name='search_catid' value='".$v."'"; }
		}
	}else{
	?>
    	<select name="search_catid">
		<?php foreach($typename_all as $v=>$k){?>
    <option value="<?php echo $v; ?>" <?php if($v==$typeid){echo "selected=\"selected\""; }?>><?php echo $k; ?></option>
        <?php }?>
    </select>
    <?php }?>
    </td>
    <td width="30%" align="right">关键字：<input type="text" name="search_key" /></td>
    <td  width="55%" align="left"><input type="submit" class="titbut" style="width:60px; float:none;" value="搜索" /></td>
  </tr>
</table>
</form>
</div>
</body>
</html>